package com.ruoyi.wms.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wms.domain.WmsMaterialStock;
import com.ruoyi.wms.service.IWmsMaterialStockService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物料现存量Controller
 * 
 * @author chao
 * @date 2024-07-23
 */
@Controller
@RequestMapping("/wms/stock")
public class WmsMaterialStockController extends BaseController
{
    private String prefix = "wms/stock";

    @Autowired
    private IWmsMaterialStockService wmsMaterialStockService;

    @RequiresPermissions("wms:stock:view")
    @GetMapping()
    public String stock()
    {
        return prefix + "/stock";
    }

    /**
     * 查询物料现存量列表
     */
    @RequiresPermissions("wms:stock:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WmsMaterialStock wmsMaterialStock)
    {
        startPage();
        List<WmsMaterialStock> list = wmsMaterialStockService.selectWmsMaterialStockList(wmsMaterialStock);
        return getDataTable(list);
    }

    /**
     * 导出物料现存量列表
     */
    @RequiresPermissions("wms:stock:export")
    @Log(title = "物料现存量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WmsMaterialStock wmsMaterialStock)
    {
        List<WmsMaterialStock> list = wmsMaterialStockService.selectWmsMaterialStockList(wmsMaterialStock);
        ExcelUtil<WmsMaterialStock> util = new ExcelUtil<WmsMaterialStock>(WmsMaterialStock.class);
        return util.exportExcel(list, "物料现存量数据");
    }


    /**
     * 删除物料现存量
     */
    @RequiresPermissions("wms:stock:remove")
    @Log(title = "物料现存量", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wmsMaterialStockService.deleteWmsMaterialStockByIds(ids));
    }
}
